package com.company.demo.service;

import com.company.demo.bean.NewsUser;
import com.company.demo.bean.Student;
import com.company.demo.dao.INewsUserDao;
import com.company.demo.dao.IStudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SomeServiceImpl implements ISomeService {

    //用户信息
    @Autowired//dao 的依赖注入
    private INewsUserDao userDao;

    @Override
    public void addUser(NewsUser User) {
        userDao.insertUser(User);
    }

    //查询信息
    @Override
    public List<NewsUser> selectUser(){
        return userDao.selectAllUser();
    }


    //学生信息
    @Autowired//dao 的依赖注入
    private IStudentDao studentDao;

    @Override
    public void addStudent(Student student) {
        //插入时会发生回滚，无法插入到DB数据库中
        studentDao.insertStudent(student);
    }

    @Override
    public List<Student> selectStudent() {

        return studentDao.selectAllStudent();

    }

}
